package com.vren.addressParse.common.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @ClassName:ResponseResult
 * @Description:
 * @Author: vren
 * @Date: 2022/6/24 14:19
 */
@Data
public class ResponseResult<T> {

    @ApiModelProperty("状态码  1成功 0失败")
    protected Integer code;
    @ApiModelProperty("提示信息")
    protected String msg;
    @ApiModelProperty("返回的数据")
    protected T data;

    public ResponseResult() {
    }

    public ResponseResult(T data, String msg, Integer code) {
        this.msg = msg;
        this.data = data;
        this.code = code;
    }

    public static ResponseResult<Boolean> success(String msg) {
        return new ResponseResult<>(true, msg, 1);
    }

    public static <T> ResponseResult<T> success(String msg, T data) {
        return new ResponseResult<>(data, msg, 1);
    }

    public static <T> ResponseResult<T> success(String msg, T data, Integer code) {
        return new ResponseResult<>(data, msg, code);
    }

    public static ResponseResult<Boolean> error(String msg) {
        return new ResponseResult<>(false, msg, 0);
    }

    public static <T> ResponseResult<T> error(String msg, T data) {
        return new ResponseResult<>(data, msg, 0);
    }

    public static <T> ResponseResult<T> error(String msg, T data, Integer code) {
        return new ResponseResult<>(data, msg, code);
    }
}
